<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>
<script>
    console.log('start');
    setTimeout(function () {
        console.log('你猜我输出在哪');
    }, 0);
    console.log('end');
    for (var i = 0; i < 10; i++) {
        console.log(i);
    }

    /* 
        start
        end
        0 ... 9
        你猜我输出在哪
    */

    console.log('start');
    for (var i = 0; i < 3; i++) {
        (function (index) {
            setTimeout(function () {
                console.log(index);
            }, 0);
        })(i);
    }
    console.log('end');

    /* 
        start
        end
        0 ... 2
    */
</script>

</html>